DevOps -CI/CD- Best Patterns and Practices

CI (Continuous Integration) and CD (Continuous Delivery) are the procedures to frequently deliver your shippable software to customers with the help of automation during the various stages of Software development. CI/CD methods address the solution to the challenges the teams face while integrating the new code in seamless fashion.


In DevOps life cycle, the CI/CD steps aid the automation along with continuous monitoring throughout the SDLC, from integration and testing phases to delivery and deployment. Connecting these steps end-end, this is referred as a "CI/CD pipeline" which bridges the Development and Operations teams to collaborate in an agile way of working . There are some extended practices to DevOps like DevSecOps and Site reliability engineering (SRE) approach.

Progressive Delivery is a modified version of Continuous Delivery in which we push the changes to a product iteratively, first to a small focus group and then to increasingly larger audiences to ensure the quality control standards.

Let’s understand couple of best patterns and practices in CI/CD with which you can devise a Progressive Delivery to your code.

Continuous Integration: Patterns and Practices

The process involved in every CI/CD method requires an application code build. When you build an application, the source code gets compiled and processed into a package of deployment version. This package is referred as an artifact in a CI/CD process. Let’s go through some practical scenarios of working with a build process using CI practices.

  • Early Automation in the Build Process

    The key exercise in a CI pipeline is to automate the build process. This build process can make use of any build tool for a specific codebase. For example, you can refer to Java build automation tools that are renowned in the JVM ecosystem – Ant, Maven, and Gradle. Within a build process, we ensure the integration and perform the unit tests, so that builds fail for code that does not meet the functional/flow requirements. Similarly, not having enough code coverage or unit tests may lead to green builds which surprise by failing in the CI/CD pipeline. So ensuring you have the unit tests is vital to a the CI process. They are cost effective in terms of resources to create and run them during each version of the build. Without this, the traditional approach of having End to End Tests are expensive and often involve rework in debugging multiple services and tedious cycle times.

  • Keep the Master Branch, Safe

    Another CI practice is to encourage the Development teams to integrate their code from the early stages and often to the main Master branch of their code repository. In the traditional approach of Development, Teams often see something called “Maintenance Hell”. Following this practice prevents that on both feature and main branches as developers diligently progress on feature development. Even if some work items are still in “work in progress”, that work remains invisible to any end-user or tester of the Master branch.

  • Immediate Fix on the broken builds

    The third CI practice involves fixing broken builds in the Master branch. Due to the Automation failures or the newly introduced changes, the tests fail resulting in the broken builds. As Continuous Integration practice believes your teams are developing on known stable versions of code , it is highly recommended to make sure the immediate fixes on them either through proper rollback steps or fixing the failure tests.

Continuous Delivery: Patterns and Practices

In the Continuous Delivery process, we ensure that all the changes passed through various deployments are delivered safe and secure to a production environment and finally to the End user who uses the product. To have these steps and outcomes enabled smoothly, some of the following Continuous Delivery patterns and practices can help

  • Automating the Delivery Lifecycle

    In the SDLC followed for any organization, the process for creating and delivering code exist with some manual steps. In Continuous Delivery pipeline we automate this process to aid the rapid delivery of Development cycle. The core Delivery steps include Environment provisioning, Supporting infrastructure, Deploying applications, Managing the Change requests and Deployment changes, Quality assurance/testing, and finally Monitoring. CD pipeline serves as Automation flow of these steps. Some maturity models refer Infrastructure as code , a practice that helps the Automation of these steps involving provision, configure, and manage infrastructure resources efficiently.

  • R & R Release and Rollback Controls

    Any Enterprise application involving medium to high complexity, needs to manage their software release cycle with a strategy in place. Anytime the release happens for the product, it involves risk of vulnerabilities, bugs, and non-performant software. There could be many causes pushing the roll back trigger for the recent deployment or look for a hotfix at the production. All these steps should be devised cautiously by Defining the release strategy that works for the organization. Some Roll back strategies ensure they complement the Release process by monitoring the key information handy like Downtime, Data loss or any major impact on the production. Teams with some process maturity use “Progressive Delivery” strategies to release new features to a customer. Some of those practices include Feature Flag management ( Launch Darkly, Canary Deployment). These are very essential skills for any team thinking of working in CI/CD pipeline.

  • Failing Fast & Safe, in Lower Environments

    Organizations following the traditional waterfall methodologies, often deal with struggling environment to adapt with dynamic landscape change. Failing fast & safe is a recommended approach in a pipeline to ensure teams have a safe and secure playground to test their changes early and do course correction in the early. But this has to be in a lean approach where teams continuously collaborate and stay transparent with the progress and help in building the right version to the Master branch. Within the SDLC, these shifting of responsibilities and activities left will offer a safe environment for Development. In short shift left mentality empowers the Development teams to stay agile and move fast without breaking things. This welcomes a great amount of innovation too. Most importantly, failing fast in the lower environments avoids frequent production incidents and rework cost associated with those.

Takeaways

The CI/CD pipeline acts as a accelerator for your SDLC process. It brings a good governance in an automated enterprise, and ensures the organization can actively manage, understand and mitigate the risk and vulnerabilities in a structured approach.

DevOps platform with robust and capable CI/CD pipelines is always a good investment organization can make. Beginning with one CI practice, like integrating tests into your CI process. will lead to ponder many other conversations around automating other relevant delivery workflows. With a healthy DevOps cycle, organizations can Scale Big and Scale Safe.